News All Tests
Current file: /home/estudydev/workspace/MSP09/web/news/tests/class.newscategoryexternaltools.inc.php
Legend: executed not executed dead code

  Coverage
  Classes Methods Lines
Total
100.00 %100.00%
100.00% 1 / 1
0.00 %0.00%
0.00% 0 / 8
2.20 %2.20%
2.20% 2 / 91
 
NewsCategoryExternalTools
100.00 %100.00%
100.00% 1 / 1
0.00 %0.00%
0.00% 0 / 8
1.11 %1.11%
1.11% 1 / 90
 public function __construct($catID, $courses, $categorySettings = NULL, $cacheObject = NULL)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 4
 public function echoNews($courseID, $usergroup = NULL)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 4
 public function isInstalled($courseID)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function canSelectPeriod()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function getNewsHeaderTitle($courseID = NULL, $type = NULL)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 5
 public function createQueryCacheObject($from, $to, $lastvisit)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 14
 protected function getNewsByPeriod($courseID, $from, $to, $lastvisit, $usergroup = NULL)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 39
 protected function echoNewsEntry($entry, $courseID, $usergroup = NULL)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 21


       1                 : <?php                                                                                                             
       2                 : /*--------------------------------------------------------------------------+                                     
       3                 : This file is part of eStudy.                                                                                      
       4                 : news/classes/class.NewsCategoryExternalTools.inc.php                                                              
       5                 : - Modulgruppe:  News                                                                                              
       6                 : - Beschreibung: Klasse für die News-Kategorie External Tools.                                                    
       7                 : - Version:      1.1.2.4, 24/01/08                                                                                 
       8                 : - Autor(en):    Corinna Kropf <corinna.kropf@mni.fh-giessen.de>                                                   
       9                 : +---------------------------------------------------------------------------+                                     
      10                 : This program is free software; you can redistribute it and/or                                                     
      11                 : modify it under the terms of the GNU General Public License                                                       
      12                 : as published by the Free Software Foundation; either version 2                                                    
      13                 : of the License, or any later version.                                                                             
      14                 : +---------------------------------------------------------------------------+                                     
      15                 : This program is distributed in the hope that it will be useful,                                                   
      16                 : but WITHOUT ANY WARRANTY; without even the implied warranty of                                                    
      17                 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                                     
      18                 : GNU General Public License for more details.                                                                      
      19                 : You should have received a copy of the GNU General Public License                                                 
      20                 : along with this program; if not, write to the Free Software                                                       
      21                 : Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.                                       
      22                 : +--------------------------------------------------------------------------*/                                     
      23                 :                                                                                                                   
      24               1 : require_once ("class.newscategory.inc.php");                                                                      
      25                 :                                                                                                                   
      26                 : /**                                                                                                               
      27                 :  * Klasse für die News-Kategorie External Tools.                                                                 
      28                 :  * @package eStudy.News                                                                                           
      29                 :  * @version 1.1.2.4, 24/01/08                                                                                     
      30                 :  * @author  Corinna Kropf <corinna.kropf@mni.fh-giessen.de>                                                       
      31                 :  */                                                                                                               
      32               1 : class NewsCategoryExternalTools extends NewsCategory                                                              
      33                 : {                                                                                                                 
      34                 :     /**                                                                                                           
      35                 :      * Cache Objekt zur Abfrage von Modulinstallationen (Performance Tweak)                                       
      36                 :      * @var array                                                                                                 
      37                 :      */                                                                                                           
      38                 :     private $installCacheObject;                                                                                  
      39                 :     /**                                                                                                           
      40                 :      * Hilfsvariable zum sortierten Anzeigen der Tools                                                            
      41                 :      * @var int                                                                                                   
      42                 :      */                                                                                                           
      43                 :     private $toolID;                                                                                              
      44                 :    /**                                                                                                            
      45                 :      * Flag fuer die Anzeige der News-Eintraege                                                                   
      46                 :      * @var bool                                                                                                  
      47                 :      */                                                                                                           
      48                 :     private $dark;                                                                                                
      49                 :    /**                                                                                                            
      50                 :      * HTML-Template                                                                                              
      51                 :      * @var Template                                                                                              
      52                 :      */                                                                                                           
      53                 :     private $toolHeaderTemplate;                                                                                  
      54                 :     /**                                                                                                           
      55                 :      * Konstruktor                                                                                                
      56                 :      */                                                                                                           
      57                 :     public function __construct($catID, $courses, $categorySettings = null, $cacheObject = null)                  
      58                 :     {                                                                                                             
      59               0 :         parent::__construct($catID, $courses, $categorySettings);                                                 
      60               0 :         $this->installCacheObject = $cacheObject;                                                                 
      61               0 :         $this->toolHeaderTemplate = new Template(PATH_TO_ROOT."news/templates/newsexternaltools_toolheader.html");
      62               0 :     }                                                                                                             
      63                 :    /**                                                                                                            
      64                 :      * Überschreibt die Methode der Oberklasse,                                                                  
      65                 :      * um weitere Initialisierungen vor der Ausgabe zu machen.                                                    
      66                 :      * @see NewsCategory                                                                                          
      67                 :      */                                                                                                           
      68                 :     public function echoNews($courseID, $usergroup = null)                                                        
      69                 :     {                                                                                                             
      70               0 :         $this->toolID = 0;                                                                                        
      71               0 :         $this->dark = false;                                                                                      
      72               0 :         parent::echoNews($courseID, $usergroup);                                                                  
      73               0 :     }                                                                                                             
      74                 :     /**                                                                                                           
      75                 :      * Muss angepasst werden, falls Modulgruppen umbenannt werden!                                                
      76                 :      * @see NewsCategory                                                                                          
      77                 :      */                                                                                                           
      78                 :     public function isInstalled($courseID)                                                                        
      79                 :     {                                                                                                             
      80               0 :         return Utilities::isInstalled("externaltools", $courseID, $this->installCacheObject);                     
      81                 :     }                                                                                                             
      82                 :     /**                                                                                                           
      83                 :      * @see NewsCategory                                                                                          
      84                 :      */                                                                                                           
      85                 :     public function canSelectPeriod() {                                                                           
      86               0 :         return false;                                                                                             
      87                 :     }                                                                                                             
      88                 :     /**                                                                                                           
      89                 :      * @see NewsCategory                                                                                          
      90                 :      */                                                                                                           
      91                 :     public function getNewsHeaderTitle($courseID = null, $type = null) {                                          
      92               0 :         $newsCount = $this->news["count"];                                                                        
      93               0 :         if ($newsCount > 1) $title = sprintf( $this->translate->_("%1\$s Registrierungen"), $newsCount);          
      94               0 :         else $title = $this->translate->_("1 Registrierung");                                                     
      95               0 :         $title.= $this->translate->_(" f&uuml;r externe Werkzeuge");                                              
      96                 :                                                                                                                   
      97               0 :         return $title;                                                                                            
      98                 :     }                                                                                                             
      99                 :                                                                                                                   
     100                 :     public function createQueryCacheObject($from, $to, $lastvisit) {                                              
     101               0 :         global $db;                                                                                               
     102                 :                                                                                                                   
     103               0 :         $waitingList = array();                                                                                   
     104                 :         $sql =   "SELECT et_signuprequests.*, et_tooldata.name "                                                  
     105                 :                         ."FROM et_signuprequests JOIN et_tooldata ON et_signuprequests.toolID=et_tooldata.ID "    
     106               0 :                         ."WHERE status=1 " // waiting...                                                          
     107               0 :                         ."ORDER BY name, timestamp";                                                              
     108               0 :         $users = $db->get_results($sql);                                                                          
     109               0 :         if ($users == null) {                                                                                     
     110                 :             // Ein leeres Array, damit beim nächsten durchlauf nicht nochmal gesucht wird                        
     111               0 :             $this->queryCacheObject["cacheObject"] = array();                                                     
     112               0 :             return false;                                                                                         
     113                 :         }                                                                                                         
     114               0 :         foreach ($users as $user) {                                                                               
     115               0 :             $waitingList[$user->courseID][$user->userID]['name'] = $user->courseID;                               
     116               0 :             $waitingList[$user->courseID][$user->userID]['userID'] = $user->name;                                 
     117               0 :         }                                                                                                         
     118                 :                                                                                                                   
     119               0 :         $this->queryCacheObject["cacheObject"] = $waitingList;                                                    
     120               0 :         return true;                                                                                              
     121                 :     }                                                                                                             
     122                 :                                                                                                                   
     123                 :     /**                                                                                                           
     124                 :      * @see NewsCategory                                                                                          
     125                 :      */                                                                                                           
     126                 :     protected function getNewsByPeriod($courseID, $from, $to, $lastvisit, $usergroup = null)                      
     127                 :     {                                                                                                             
     128                 :                                                                                                                   
     129               0 :         if ($_SESSION["course"] == 0 || $this->queryCacheObject != null) {                                        
     130               0 :             if ($this->queryCacheObject == null) {                                                                
     131               0 :                 if (!$this->createQueryCacheObject($from, $to, $lastvisit))                                       
     132               0 :                     return null;                                                                                  
     133               0 :             }                                                                                                     
     134               0 :             if ($this->queryCacheObject == null)                                                                  
     135               0 :                 return null;                                                                                      
     136               0 :             $cacheObject =  $this->queryCacheObject["cacheObject"];                                               
     137               0 :             if (!array_key_exists($courseID, $cacheObject))                                                       
     138               0 :                 return null;                                                                                      
     139               0 :             $waitingList = $cacheObject[$courseID];                                                               
     140               0 :             $numWaiting = count($waitingList);                                                                    
     141               0 :             if ($numWaiting == 0)                                                                                 
     142               0 :                 $this->news = null;                                                                               
     143                 :             else {                                                                                                
     144               0 :                 foreach($this->news["data"] as $registration) {                                                   
     145               0 :                     $this->users[$registration["userID"]] = $registration["userID"];                              
     146               0 :                    }                                                                                              
     147               0 :                 $this->news["data"] = $numWaiting;                                                                
     148               0 :                 $this->news["count"] = $numWaiting;                                                               
     149                 :             }                                                                                                     
     150               0 :             return $this->news;                                                                                   
     151                 :         }                                                                                                         
     152                 :         // Neue Registrierungen für externe Werkzeuge                                                            
     153               0 :         if (isset($courseID) && isset($lastvisit))                                                                
     154               0 :         {                                                                                                         
     155               0 :             if(!is_numeric($courseID) || !is_numeric($lastvisit) || !is_numeric($usergroup)) return null;         
     156                 :                                                                                                                   
     157               0 :             if ($usergroup == ADMIN || ($usergroup == DOZENT && $courseID > 0))                                   
     158               0 :             {                                                                                                     
     159               0 :                 global $db;                                                                                       
     160               0 :                 $this->news = array();                                                                            
     161                 :                                                                                                                   
     162                 :                 $sql =   "SELECT et_signuprequests.*, et_tooldata.name "                                          
     163                 :                         ."FROM et_signuprequests JOIN et_tooldata ON et_signuprequests.toolID=et_tooldata.ID "    
     164               0 :                         ."WHERE courseID='".Data::toMysql($courseID)."' "                                         
     165                 :                     //  ."AND timestamp BETWEEN $lastvisit AND ".time()." "                                       
     166               0 :                         ."AND status=1 " // waiting...                                                            
     167               0 :                         ."ORDER BY name, timestamp";                                                              
     168               0 :                 $this->news["data"] = $db->get_results($sql, ARRAY_A);                                            
     169               0 :                 $this->news["count"] = $db->num_rows;                                                             
     170               0 :                 if ($db->num_rows == 0) $this->news = null;                                                       
     171                 :                 else                                                                                              
     172                 :                 {                                                                                                 
     173               0 :                        foreach($this->news["data"] as $registration) {                                            
     174               0 :                            $this->users[$registration["userID"]] = $registration["userID"];                       
     175               0 :                        }                                                                                          
     176                 :                 }                                                                                                 
     177               0 :             }                                                                                                     
     178               0 :         }                                                                                                         
     179                 :                                                                                                                   
     180               0 :         return $this->news;                                                                                       
     181                 :     }                                                                                                             
     182                 :     /**                                                                                                           
     183                 :      * @see NewsCategory                                                                                          
     184                 :      */                                                                                                           
     185                 :     protected function echoNewsEntry($entry, $courseID, $usergroup = null)                                        
     186                 :     {                                                                                                             
     187               0 :         if(!isset($this->dark) || !isset($entry) || !isset($courseID) || !isset($this->news["user"])) return;     
     188                 :                                                                                                                   
     189               0 :         if ($courseID == 0) {                                                                                     
     190               0 :             $cellStyle = ($this->dark ? "Dark" : "");                                                             
     191               0 :             if ($this->toolID != $entry["toolID"]) {                                                              
     192               0 :                 $toolName = Data::toHTML($entry["name"], false);                                                  
     193               0 :                 $externalToolsScript = PATH_TO_ROOT."externaltools/externaltool.admin.php";                       
     194                 :                                                                                                                   
     195               0 :                 $g_Warteliste = $this->translate->_("Warteliste");                                                
     196                 :                                                                                                                   
     197               0 :                 eval($this->toolHeaderTemplate->GetTemplate());                                                   
     198               0 :             }                                                                                                     
     199               0 :             foreach($this->news["data"] as $registration) {                                                       
     200               0 :                 if($registration["userID"]==$entry["userID"])                                                     
     201               0 :                     break;                                                                                        
     202               0 :             }                                                                                                     
     203                 :             echo "<tr>"                                                                                           
     204               0 :                 ."<td class='tableCell".$cellStyle ."'>"                                                          
     205               0 :                 .Output::getUsergroupPicture($entry["userID"], STUDENT)                                           
     206               0 :                 ."&nbsp; "                                                                                        
     207               0 :                 .$this->getProfileLink($this->news["user"], $entry["userID"], $courseID)                          
     208               0 :                 ."</td>"                                                                                          
     209               0 :                 ."</tr>";                                                                                         
     210               0 :         }                                                                                                         
     211               0 :     }                                                                                                             
     212                 : }                                                                                                                 

Generated by PHPUnit 3.2.21 and Xdebug 2.0.4 at Sat Nov 7 22:04:08 CET 2009.